Color Code Converter

Convert freely between HEX, RGB and HSL

RGB
HSL

What this tool does

Edit any one of the HEX code, the three RGB values or the three HSL values, or pick a color with the color picker, and the other notations update instantly while the swatch at the top fills with that color. RGB and HSL have copy buttons that produce CSS-ready strings (rgb(…), hsl(…)). Use it to move colors from a design mockup into code, to make lighter or darker variants of a brand color, or to see what color a code someone sent you actually is.

How it is calculated

The three notations describe the same color in different ways. HEX writes red, green and blue as two hex digits each (#RRGGBB), RGB as integers from 0 to 255, and HSL as hue angle (0 to 360 degrees), saturation (0 to 100%) and lightness (0 to 100%). The tool keeps a single RGB value internally; whichever field changes is converted to RGB and the others are recalculated. The HEX field works with or without #, expands three-digit shorthand like #F80 to #FF8800, and displays the result in uppercase. Out-of-range numbers are clamped to 0 to 255, 0 to 360 or 0 to 100. For example, entering FF8800 gives RGB 255, 136, 0 and HSL 32, 100%, 50%. Lowering only L from 50 to 30 then gives a darker version of the same orange, #995200 (153, 82, 0). Everything is calculated in your browser.

  • #FF8800 = rgb(255, 136, 0) = hsl(32, 100%, 50%)
  • Two hex digits map to 0 to 255: FF = 255, 80 = 128, 00 = 0
  • Three-digit shorthand #F80 equals #FF8800, with each digit doubled.
  • Changing only HSL's L gives lighter or darker versions; changing only S gives more vivid or duller ones.
  • H of 0 is red, 120 green, 240 blue, and 360 wraps back to red.

Things to know

  • Use HSL's L field to fine-tune lightness. Doing the same in RGB means adjusting all three values proportionally.
  • HSL values are shown rounded to integers, so editing HSL can shift RGB by about 1. When an exact code matters, edit in the HEX or RGB fields.
  • Transparency (alpha) is not handled. The HEX field accepts only six digits, so add rgba or an 8-digit HEX yourself in CSS if you need translucency.
  • HEX has no copy button, but you can select the field's value and copy it.
  • Screens (additive RGB light) and print (layered ink) work differently, so the same code can look duller in print.
  • Once you pick a color, check text-to-background contrast. A pretty color is not always a readable one.

Frequently asked questions

Should I use HEX or RGB?

They carry exactly the same information, so either works. HEX is shorter and common in code; RGB or HSL is handier when calculating or adjusting values.

What does HSL's H value mean?

It is the angle on the color wheel: 0 red, 60 yellow, 120 green, 180 cyan, 240 blue, 300 magenta, and 360 back to red.

The same code looks different on different screens.

Devices differ in color gamut and calibration. The code is the same but the display differs, so check important colors on the device that will show them.

Can it convert to print color values?

This tool handles only the three screen notations (HEX, RGB, HSL). Print values depend on paper and press settings, so a simple conversion is not accurate; follow your printer's or design software's standards.

← na.to home